<% layout('/layout/default.html', {title: '角色管理', libs: ['layui']}){ %>
<div class="main-content">
		<div class="card-header">
				<i class="fa fa-cubes"></i> 角色管理
			<div class="header-tools float-right">
				<% if(hasPermi('sys:role:edit')){ %>
					<a href="/sys/role/form" class="btn btn-default btn-sm btnTool"  title="新增角色"><i class="fa fa-plus"></i> 新增</a>
				<% } %>
			</div>
		</div>
		<div class="container-fluid">
			<form id="searchForm" action="${ctx}/sys/role/listData" method="post" class="form-inline d-none" >
				<div class="form-group">
					<button type="submit" class="btn btn-success btn-sm ">查询</button>
					<button type="reset" class="btn btn-default btn-sm">重置</button>
				</div>
			</form>			
			<table id="btGrid"></table>
		</div>
</div>
<% } %>
<script>
//初始化layui-table对象
$('#btGrid').BTGrid({
	searchForm: $("#searchForm"),
	page: false,
	columnModel: [
		{title:'角色名称', field:'name'},
		{title:'英文名称', field:'enname'},
		{title:'用户类型', templet: function(row){
			return js.transDictLabel(${@DictUtils.getDictListJson('sys_user_type')}, row.userType, '<font color=#aaa>未设置</font>');
		}},
		{title:'归属机构', templet: function(row){
			return row.office.name;
		}},
		{title:'数据范围', templet: function(row){
                return js.transDictLabel(${@DictUtils.getDictListJson('sys_data_scope')}, row.dataScope, '');
		}},
		{title:'操作', templet: function(row){
			var actions = [];
			<% if(hasPermi('sys:role:edit')){ %>
			
				actions.push('<a href="/sys/role/assign?id='+row.id+'" class="btn btn-xs btn-success btnList" title="分配用户"><i class="fas fa-user"></i></a>&nbsp;&nbsp;');
				actions.push('<a href="/sys/role/form?id='+row.id+'" class="btn btn-xs btn-primary btnList" title="编辑角色"><i class="far fa-edit"></i></a>&nbsp;&nbsp;');
				actions.push('<a href="${ctx}/sys/role/delete?id='+row.id+'" class="btn btn-xs btn-danger btnList" title="删除角色" data-confirm="确认要删除该角色吗？"><i class="far fa-trash-alt"></i></a>');
				
			<% } %>
			
			return actions.join('');
		}}
	],
	// 加载成功后执行事件
	ajaxSuccess: function(data){
		
	}
});

</script>